Release 10.1A: OpenEdge Data Management:
DataServer for Microsoft SQL Server
RDBMS stored procedure basics
In the OpenEdge environment, you can think of a stored procedure definition as having two basic, interrelated parts:
- Execution controls to run and close a store procedure — Comprise the information needed to execute a stored procedure request against the MS S data source. At a minimum, all stored procedures discussed in this guide are assessable using the
RUN STORED-PROCEDUREstatement.- Language elements that enable access to specific data results — Qualify the retrieved data, or result sets, that the stored procedure’s execution returns. Various keywords, phrases, statements, and syntax elements support different retrieval options for stored procedure output. This part of the stored procedure implementation reflects your analysis of your data needs; based on this analysis, you determine the additional syntax elements you need to define the output elements and data results you want retrieved.
Table 3–1 identifies and briefly introduces the elements that comprise a stored procedure definition; each of these elements is also more fully discussed later in this chapter.
Note: You can substitute the abbreviations
RUNSTORED–PROCandCLOSESTORED–PROCfor the full namesRUNSTORED–PROCEDUREandCLOSESTORED–PROCEDURE, respectively. The remainder of this guide generally uses the abbreviated form.See the "Run Stored-Procedure details" section for more details about the reference entries presented in Table 3–1.
As previously noted in Table 3–1, you can pass data types in the
RUN STORED-PROCEDUREstatement using thePARAMphrase. Table 3–2 lists issues that occur when you pass certain data types as parameters.
Note these stored procedure points:
- Input and output parameters are displayed as fields.
- Stored procedures called from within OpenEdge applications cannot return Boolean values to
LOGICALdata types.- If you are running several stored procedures, run them serially and process all the results from one stored procedure and close the procedure before you run a second one. By default, the DataServer allows one active request for running a stored procedure. It is not necessary to specify the
PROC-HANDLEphrase when procedures are run serially.When you run stored procedures concurrently, the DataServer uses one connection to the data source per procedure. If different stored procedures attempt to update the same record from a single client’s requests, the connections could block each other or a deadlock might occur.
Note: You must define aPROC-HANDLEphrase for each stored procedure phrase that is simultaneously active. This technique provides aCLOSE STORED-PROCstatement that can identify the targeted open procedure and close it.
In contrast, since a stored procedure executed with theLOAD-RESULT-INTOphrase implicitly closes the procedure once the execution ends and the data retrieved is placed into temp tables, it essentially runs serially and has no use for aPROC-HANDLE.
- When you create or update your schema image, the stored procedures appear in the list of accessible objects along with tables, view, and sequences. OpenEdge allows you to run the stored procedures that you create in data sources using the procedure definitions in your schema image. See your Microsoft SQL Server documentation for complete information about creating and using stored procedures.
- If the 4GL that executes a stored procedure is already within a transaction block, the stored procedure becomes an extension of that transaction and will not commit to the database until the 4GL transaction is completed. However, because the stored procedure does not execute as part of the 4GL client process, it cannot be rolled back by the 4GL.
- The DataServer cannot roll back sub-transactions in the stored-procedure context since it has no control over what the stored procedure executes.
The following sections expand on the use of the
RUN STORED-PROCstatement.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |